Skip to content

#3071: create new directory setting and use for '-d' parameter #3120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 20, 2017

Conversation

esarbe
Copy link
Contributor

@esarbe esarbe commented Sep 13, 2017

also make sure that directory exists when updating setting

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@@ -158,6 +161,10 @@ object Settings {
case Success(v) => update(v, args)
case Failure(ex) => fail(ex.getMessage, args)
}
case (DirectoryTag, arg :: args) =>
val path = Path(arg)
if (path.isDirectory) update(arg, args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it should be update(path.toDirectory, args)

@@ -17,7 +18,7 @@ class ScalaSettings extends Settings.SettingGroup {
val javaextdirs = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs)
val sourcepath = PathSetting("-sourcepath", "Specify location(s) of source files.", "") // Defaults.scalaSourcePath
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
val d = DirectorySetting("-d", "directory|jar", "destination for generated classfiles.", Directory(Path(".")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably rename this setting to something like outputDir

@esarbe
Copy link
Contributor Author

esarbe commented Sep 18, 2017

I've had to touch up the tests so that the output directory actually exists.

@allanrenucci
Copy link
Contributor

Could you add a test under compiler/test/dotty/tool/dotc/SettingTests.scala and do something like:

class SettingTests {
  ...

  @Test def missingOutputDir: Unit = {
    val options = Array("-d", "not_here")
    val reporter = Main.process(options)
    assertEquals(reporter.errorCount, 1)
    assertEquals(reporter.allErrors.head.message, "'not_here' does not exist or is not a directory")
  }
}

@esarbe
Copy link
Contributor Author

esarbe commented Sep 20, 2017

Sure thing!

@smarter
Copy link
Member

smarter commented Sep 20, 2017

Nitpick: To automatically close the issue when a PR is merged, you should put "Fix #nnnn" in the commit message, just putting "#nnnn" is not enough.

@esarbe
Copy link
Contributor Author

esarbe commented Sep 20, 2017

Thanks for the nitpicking! I've updated the last commit comment, I hope that suffices.

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for your contribution!

@allanrenucci allanrenucci merged commit 098afe1 into scala:master Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants